#! -*- coding: utf-8 -*-

from django.shortcuts import render_to_response
from django.template import RequestContext, Template, Context
from models import Estatico
from configuration.models import PageData
from conteudo.models import Post

def estatico(request, pagina):
    page = "conteudo_estatico.html"
    obj = eval("Estatico.objects.get(link='%s')" % pagina)
    t = Template(obj.conteudo)
    
    data = PageData()

    label = obj.label
    conteudo = t.render(Context())
    
    return render_to_response('index.html', locals(),
                              context_instance=RequestContext(request))

def post(request, post):
    
    data = PageData()
    post = Post.objects.filter(id=post)
    if len(post) > 0:
        post = post[0]
    else:
        post = None
    page = 'post.html'
    return render_to_response('index.html', locals(),
                              context_instance=RequestContext(request))

